﻿using System.Collections.Generic;
using Microsoft.Extensions.Primitives;

namespace K9Nano.Security
{
    /// <summary>
    /// 参数签名及校验接口
    /// </summary>
    public interface IUrlSignManager
    {
        /// <summary>
        /// 创建签名
        /// </summary>
        /// <param name="salt">签名盐</param>
        /// <param name="query">请求参数及值</param>
        /// <returns>签名字符串</returns>
        string Create(string salt, IDictionary<string, string> query);

        /// <summary>
        /// 校验签名
        /// </summary>
        /// <param name="query">请求参数及值</param>
        /// <param name="salt">签名盐</param>
        /// <param name="signParameter"><see cref="query"/>中签名字符串的Key</param>
        /// <returns>是否校验成功</returns>
        bool Verify(IEnumerable<KeyValuePair<string, StringValues>> query, string salt, string signParameter = "sign");

        /// <summary>
        /// 校验签名
        /// </summary>
        /// <param name="query">请求参数及值</param>
        /// <param name="salt">签名盐</param>
        /// <param name="signParameter"><see cref="query"/>中签名字符串的Key</param>
        /// <returns>是否校验成功</returns>
        bool Verify(string query, string salt, string signParameter = "sign");
    }
}